<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        var str = 'http://127.0.0.1:5500/day12/%E8%AF%BE%E5%A0%82%E4%BB%A3%E7%A0%81/html/06search.html?username=yy&userpwd=123&usertel=188888';




        // [
        //     ['username' , 'yy'] ,
        //     ['userpwd' , '123']
        // ]

        // [
        //     {
        //         username : 'yy'
        //     } ,
        //     {
        //         userpwd : '123'
        //     }
        // ]

        var arr = str.split('?');
        console.log(arr);

        var str2 = arr[1];
        console.log(str2);   // username=yy&userpwd=123


        var arr2 = str2.split('&');
        console.log(arr2);   // ['username=yy', 'userpwd=123']

        // var arr3 = [];
        // for (var i in arr2) {
        //     var v = arr2[i].split('=');
        //     arr3.push(v);
        // }
        // console.log(arr3);

        // var arr3 = arr2.map(function (v, i) {
        //     return v.split('=')
        // })
        // console.log(arr3);

        var arr3 = arr2.map(function (v, i) {
            var obj = {};
            var arr4 = v.split('=');
            obj[arr4[0]] = arr4[1];
            return obj
        })

        console.log(arr3);



    </script>

</body>

</html>